package com.example.dell.utils;

import android.os.Handler;
import android.os.Looper;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/**
 * 子线程和主线程切换使用
 */
public class ThreadUtil {
    private static Executor executor = Executors.newSingleThreadExecutor();
    private static Handler  handler  = new Handler(Looper.getMainLooper());

    public static void executeSubThread(Runnable runnable) {
        executor.execute(runnable);
    }

    public static void executeMainThread(Runnable runnable) {
        handler.post(runnable);
    }

}
